package com.enroll.dao.impl;

import java.util.List;

import org.springframework.stereotype.Repository;

import com.enroll.dao.StudentDao;
import com.enroll.model.Student;
import com.enroll.util.CustomHibernateDaoSupport;

@Repository("studentDao")
public class StudentDaoImpl extends CustomHibernateDaoSupport implements StudentDao {

	
	@Override
	public void save(Student student) {
		getHibernateTemplate().save(student);
	}

	@Override
	public void delete(Student student) {
		getHibernateTemplate().delete(student);
		
	}

	@Override
	public void update(Student student) {
		getHibernateTemplate().update(student);
		
	}

	@Override
	@SuppressWarnings("rawtypes")
	public Student findById(int id) {
		List list = getHibernateTemplate().find("from Student where id=?",id);
		return (Student) list.get(0);
		
	}

	@Override
	@SuppressWarnings("unchecked")
	public List<Student> findAll() {
		List<Student> students = getHibernateTemplate().find("from Student");
		return students;
	}

}
